<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>
<div class="admin_nrtop">
    <div class="ad_search">
        <form action="/admini/generalize/receivedetail/"  method="get" style="margin:0px" id="form1">
        <div class="search">
            <div class="soubox">
                <input type="text" id="quick" name="quick" value="<?php echo $this->quick?$this->quick:"";?>" placeholder="输入活动的名称/内容等"/>
                <input type="hidden" id="gelId" name="gelId" value="<?php echo $this->gelId?$this->gelId:"";?>"/>
                <input type="hidden" id="starttime" name="starttime" value="<?php echo $this->starttime?$this->starttime:"";?>"/>
                <input type="hidden" id="endtime" name="endtime" value="<?php echo $this->endtime?$this->endtime:"";?>" />
                <input type="hidden" id="pagesize" name="pagesize" value="<?php echo $this->pagesize?$this->pagesize:10;?>" />
                <input type="hidden" id="grantType" name="grantType" value="<?php echo $this->grantType?$this->grantType:"";?>" />
                <input type="hidden" id="giftType" name="giftType" value="<?php echo $this->giftType?$this->giftType:"";?>" />
                <input type="hidden" id="giftId" name="giftId" value="<?php echo $this->giftId?$this->giftId:"";?>" />
            </div>
            <a href="javascript:$('#form1').submit();"><span>搜索</span></a>
        </div>

        <div class="timebox">
            <div class="ad_time">
                <div class="timezdy">
                    <div class="timeselect2">
                        <span>选择时间</span><i></i>
                    </div>
                </div>
                <div class="timefw">
                    <div class="time">
                        <!--点击后悬停样式为：<div class="timeselect t_on">-->
                        <div class="timeselect"  id="stime">
                            <span id="stimeval"><?php echo $this->starttime?$this->starttime:date("Y-m-d",mktime(0,0,0,date("m"),date("d")-90,date("Y")));?></span><i></i>
                        </div>
                        <div class="timeslelctbox">
                            <!---时间插件放此DIV-->
                        </div>
                    </div>
                    <div class="timezhi">
                        <span>至</span>
                    </div>
                    <div class="time" >
                        <div class="timeselect" id="etime">
                            <span id="etimeval"><?php echo $this->endtime?$this->endtime:date("Y-m-d");?></span><i></i>
                        </div>
                        <div class="timeslelctbox">
                            <!---时间插件放此DIV-->
                        </div>
                    </div>
                </div>
            </div>
            <div class="timeok">
                <a href="javascript:$('#form1').submit();">确定</a>
            </div>
        </div>
        <div class="xianshi">
            <label>显示：</label>
            <ul>
                <li <?php echo $this->pagesize?($this->pagesize==10?'class="xson"':""):'class="xson"'; ?>><a href="javascript:void(0)" name="10" class="setOption" i="pagesize">10</a></li>
                <li <?php echo $this->pagesize?($this->pagesize==20?'class="xson"':""):""; ?>><a href="javascript:void(0)" name="20" class="setOption" i="pagesize">20</a></li>
                <li <?php echo $this->pagesize?($this->pagesize==30?'class="xson"':""):""; ?>><a href="javascript:void(0)" name="30" class="setOption" i="pagesize">30</a></li>
            </ul>
        </div>
        </form>
    </div>
</div>
<div  class="biaoge">
    <div class="biaotbody">
        <table>
            <tr>
                <th class="li9">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>活动名称</span>
                            <i></i>
                        </div>
                        <div class="biaoxllb" style="display:none;">
                            <ul>
                                <?php if($this->generalizeAll){ foreach ($this->generalizeAll as $generalizeVal) { ?>
                                    <li><a href="javascript:void(0)" name="<?php echo $generalizeVal->Id;?>" class="setOption" i="gelId"><?php echo $generalizeVal->Name; ?></a></li>
                                <?php }} ?>
                            </ul>
                        </div>
                    </div>
                </th>
                <th class="li5">
                    <div class="lileft"><span>时间</span></div>
                </th>
                <th class="li5">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>领取类型</span>
                            <i></i>
                        </div>
                        <div class="biaoxllb" style="display:none;">
                            <ul>
                                <?php if($this->grantAll){ foreach ($this->grantAll as $grantKey => $grantVal) { ?>
                                    <li><a href="javascript:void(0)" name="<?php echo $grantKey;?>" class="setOption" i="grantType"><?php echo $grantVal; ?></a></li>
                                <?php }} ?>
                            </ul>
                        </div>
                    </div>
                </th>                
                <th class="li5">
                    <div class="lileft"><span>领取关联/数量</span></div>
                </th>
                <th class="li5">
                    <div class="lileft"><span>用户信息</span></div>
                </th>
                <th class="li5">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>礼物类型</span>
                            <i></i>
                        </div>
                        <div class="biaoxllb" style="display:none;">
                            <ul>
                                <?php if($this->giftTypeAll){ foreach ($this->giftTypeAll as $giftTypeKey => $giftTypeVal) { ?>
                                    <li><a href="javascript:void(0)" name="<?php echo $giftTypeKey;?>" class="setOption" i="giftType"><?php echo $giftTypeVal; ?></a></li>
                                <?php }} ?>
                            </ul>
                        </div>
                    </div>
                </th>
                <th class="li5">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>礼物名称</span>
                            <i></i>
                        </div>
                        <div class="biaoxllb" style="display:none;">
                            <ul>
                                <?php if($this->giftAll){ foreach ($this->giftAll as $giftTypeKey => $giftTypeVal) { ?>
                                    <li><a href="javascript:void(0)" name="<?php echo $giftTypeKey;?>" class="setOption" i="giftId"><?php echo $giftTypeVal; ?></a></li>
                                <?php }} else {  ?>
                                    <li><a href="javascript:void(0)" name="" class="setOption" i="giftType">请选择礼物类型</a></li>
                                <?php } ?>
                            </ul>
                        </div>
                    </div>
                </th>
                <th class="li5">
                    <div class="lileft"><span>领取数量</span></div>
                </th>
            </tr>
        </table>
    </div>
    <?php if(($this->grantType !== "") || ($this->giftType !== "") || ($this->giftId !== "") || ($this->generalizeItem !== "") ){?>
        <div class="xzinfo">
          <ul>
              <?php if($this->generalizeItem){ ?><li><div class="xzinfobox"><span><?php echo $this->generalizeItem->Name;?></span><a href="javascript:void(0)" class="removeOp" title="撤销" name="gelId"><i>撤销</i></a></div></li><?php }?>
              <?php if($this->giftType != ""){ ?><li><div class="xzinfobox"><span><?php echo $this->giftTypeAll[$this->giftType];?></span><a href="javascript:void(0)" class="removeOp" title="撤销" name="giftType"><i>撤销</i></a></div></li><?php }?>
              <?php if($this->grantType != ""){ ?><li><div class="xzinfobox"><span><?php echo $this->grantAll[$this->grantType];?></span><a href="javascript:void(0)" class="removeOp" title="撤销" name="grantType"><i>撤销</i></a></div></li><?php }?>
              <?php if($this->giftId != ""){ ?><li><div class="xzinfobox"><span><?php echo $this->giftAll[$this->giftId];?></span><a href="javascript:void(0)" class="removeOp" title="撤销" name="grantType"><i>撤销</i></a></div></li><?php }?>
          </ul>
        </div>
     <?php }?>
     <div class="table">
         <table>
             <?php if($this->receiveList){
                 foreach ($this->receiveList as $Item) { ?> 
                 <tr>
                     <td class="li9">
                         <div class="lileft">
                             <?php echo $Item->GeneralizeItem->Name;?>
                         </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->dateCreated;?>
                         </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->RuleItem->GrantName;?>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php if($Item->RuleItem->ruleLimit == Application_Model_GeneralizeRule::RuleLimit_Sum) { ?>
                                <?php $glHref = $Item->getGlHref($Item->RuleItem->grantType); ?>
                             <a href="<?php echo $glHref["href"]?>" class="indexa" target="_blank"><?php echo $glHref["name"];?></a>
                             <?php } else {echo $Item->receiveId;}?>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->UserInfo->nikename."<br>".$Item->UserInfo->storeno;?>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->RuleItem->GiftTypeName;?>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->RuleItem->GiftName;?>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->RuleItem->ruleNum;?>
                        </div>
                     </td>
                 </tr>
             <?php }  } else {
                echo "<font size='4' color='red'>暂无数据</font>";
                }?>   
         </table>
     </div>
 </div>
<div class="toolbar">
    <div class="qunx">
        <ul>
            <li><a class="anvbotton" href="javascript:void(0)" id="addGeneralize" name="addGeneralize"><span>添加活动</span></a></li>
        </ul>
    </div>
<?php
    echo $this->partial('paging.phtml', array("pages" => $this->receiveAll,"pamas"=>"quick=$this->quick&timescope=$this->timescope&starttime=$this->starttime&endtime=$this->endtime&pagesize=$this->pagesize&cityId=$this->cityId&status=$this->status"));        
?>
</div>
<script>
    $(function(){
        $("#stime").click(function(){
            $(this).attr("class","timeselect t_on");
            WdatePicker({el:'stimeval',vel:'starttime',onpicked:function(){
                    $("#stime,#etime").attr("class","timeselect");
                    $(".soubox #timescope").val("");
            }});
        });
        $("#etime").click(function(){
            $(this).attr("class","timeselect t_on");
            WdatePicker({el:'etimeval',vel:'endtime',onpicked:function(){
                    $("#stime,#etime").attr("class","timeselect");
                    $(".soubox #timescope").val("");
            }});
        });
        $(".timezdy").click(function(){
            $(".timezdy .timeselect2").attr("class","timeselect2 timeon");
            $(".timeslelct_xl").show();
        });
        $(".timezdy").mouseleave(function(){
           $(".timeselect2").attr("class","timeselect2");
           $(".timeslelct_xl").hide();
        });
        $(".lixiala").click(function(){
            $(".lixiala").attr("class","lixiala");
            $(".lixiala").next("div").hide();

            $(this).attr("class","lixiala bton");
            $(this).next("div").show();
        });
        $('.countryzm a').each(function(index,item){
            $(item).click(function(){
                $('.countryzm li.zmon').removeClass('zmon');
                $(this).parent().addClass('zmon');
                $('#countryTab ul').hide();
                $('#countryTab ul').eq(index).show();
                return false;
            });
        });
        $('.countrylist a').bind('click',function(){
            $(".soubox #cityId").val($(this).attr('cid'));
            $('#form1').submit();
        });
        $(document).bind("click",function(e){
            var target  = $(e.target);
            if(target.closest(".biaoxiala").length == 0){
                $(".lixiala").attr("class","lixiala");
                $(".lixiala").next("div").hide();
            }
            if(target.closest("#stime").length == 0){
                $("#stime").attr("class","timeselect");
            }
            if(target.closest("#etime").length == 0){
                $("#etime").attr("class","timeselect");
            }
       });
       $(".setOption").click(function(){
          var type = $(this).attr("name");
          var option = $(this).attr("i");
          $("#form1 #"+option).val(type);
          $("#form1").submit();
       });
       $(".removeOp").click(function(){
          var option = $(this).attr("name");
          $("#form1 #"+option).val("");
          $("#form1").submit();
       });
       $("#addGeneralize").click(function(){
          location.href='/admini/generalize/addgeneralizd';
       });
    });
</script>